package com.lk.client.loadbanlance;

/**
 * @author kun.li
 */
public enum RouteStrategy {

    RANDOM("random", new RandomRoute()),
    ROUND("round", new RoundRoute()),
    FIRST("first", new FirstRoute()),
    LAST("last", new LastRoute());

    public final String name;
    public final Route route;

    RouteStrategy(String name, Route route) {
        this.name = name;
        this.route = route;
    }

    public static Route getRoute(String name){
        for (RouteStrategy value : RouteStrategy.values()) {
            if (value.name.equals(name)) {
                return value.route;
            }
        }
        throw new RuntimeException("");
    }
}
